﻿using UnityEngine;

[ExecuteInEditMode]
public class CircleCamera : CircleArea
{
    private float m_xmin;
    private float m_xmax;
    private float m_zmin;
    private float m_zmax;
    private float m_xwidth;
    private float m_zwidth;


    internal void Awake()
    {
        var camTerrain = Terrain.activeTerrain;
        var ori = camTerrain.transform.position;
        m_xwidth = camTerrain.terrainData.size.x;
        m_zwidth = camTerrain.terrainData.size.z;
        m_xmin = ori.x - m_xwidth / 2f;
        m_xmax = ori.x + m_xwidth + m_xwidth / 2f;
        m_zmin = ori.z - m_zwidth / 2f;
        m_zmax = ori.z + m_zwidth + m_zwidth / 2f;
    }


    public override float Xmin
    {
        get { return m_xmin; }
    }

    public override float Xmax
    {
        get { return m_xmax; }
    }

    public override float Zmin
    {
        get { return m_zmin; }
    }

    public override float Zmax
    {
        get { return m_zmax; }
    }

    public override float Xwidth
    {
        get { return m_xwidth * 2; }
    }

    public override float Zwidth
    {
        get { return m_zwidth * 2; }
    }
}
